using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using Notifications.Runtime;
using UnityEngine;

namespace Notifications.Test
{
    public class TestBackground : MonoBehaviour
    {
        private IGameBackgroundNotification _backgroundNotification;

        private void Awake()
        {
            
        }

        // Start is called before the first frame update
        void Start()
        {
            _backgroundNotification = GameNotificationsManager.Instance.CreateBackgroundNotification();
            _backgroundNotification.Id = 100;
            _backgroundNotification.Body = DateTime.Now.ToString();
            _backgroundNotification.Title = "后台显示";
            _backgroundNotification.Channel = EChannelType.Default;
            GameNotificationsManager.Instance.ScheduleBackgroundNotification(_backgroundNotification);
            
            GameNotificationsManager.Instance.UpdateBackgroundNotification(_backgroundNotification);

            Test();
        }


  

        private Thread thread = null;
        private void Test()
        {
            int progress = 0;
            thread = new Thread(() =>
            {
                while (GameNotificationsManager.IsInstanceCreated)
                {
                    Thread.Sleep(1000);
                    progress++;
                    if (progress == 30)
                    {
                        _backgroundNotification.Body = "下载完成";
                        _backgroundNotification.Channel = EChannelType.Max;
                        GameNotificationsManager.Instance.UpdateBackgroundNotification(_backgroundNotification);
                        break;
                    }
                    _backgroundNotification.Body = DateTime.Now.ToString();
                    GameNotificationsManager.Instance.UpdateBackgroundNotification(_backgroundNotification);
                }
            });
            thread.Start();
       
        }

        // Update is called once per frame
        void Update()
        {
        
        }
    }  
}

